using Godot;
using System;

public partial class Caoxue : Node2D
{

	public ulong shenchangshiji = 5000;
	public bool shengchangkaiguan =true;
	public bool jishizhong = false;
    public ulong shengchangkaishi;
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
	{
	}

	// Called every frame. 'delta' is the elapsed time since the previous frame.
	public override void _Process(double delta)
	{

		if (shengchangkaiguan) 
		{ 
			if (!jishizhong)
			{
				shengchangkaishi = Time.GetTicksMsec();
			
				jishizhong = true;

			}
			//else
			//{
			//	shengchangkaishi -= Time.GetTicksMsec();
			//}
			if (shengchangkaishi + shenchangshiji< Time.GetTicksMsec())
			{
			
				var em= GD.Load<PackedScene>("res://em.tscn");
				var caonagishi = em.Instantiate<Em>();
				GetParent().AddChild(caonagishi);
				caonagishi.Position = Huoquweizhi();
				caonagishi.yuandian = Huoquweizhi();
				caonagishi.play_node = GetParent().GetNode<Play>("Play");
				//caonagishi.isMove = false;
				shengchangkaiguan = false;

				jishizhong =false;
			}
        }
    }

	public Vector2 Huoquweizhi() 
	{
        //先对自身周围的空间进行检测 看是否有空位
		
        return  Position+new Vector2(16,16);
    }

}
